package l1cache

import (
	"sync"
	"time"
)

var timeout_clean float64 = 86400

type statBase struct {
	sync.RWMutex
	activeTime time.Time //信息活跃时间
	createTime time.Time //缓存创建时间
}

func newStatBase() statBase {
	return statBase{
		activeTime: time.Now(),
		createTime: time.Now(),
	}
}

func (_this *statBase) setActiveTime() {
	_this.activeTime = time.Now()
}

func (_this *statBase) getActiveTime() time.Time {
	return _this.activeTime
}

func (_this *statBase) checkActive() bool {
	// runtime := time.Now().Sub(_this.activeTime).Seconds()
	runtime := time.Since(_this.activeTime).Seconds()
	return runtime > timeout_clean

}
